<template>
  <view class="applyAfterSales_container">
    <!-- 订单状态 -->
    <view class="orderStatus">
      <view>
        订单编号：
        <text>{{ sn }}</text>
      </view>
      <view>
        订单状态：
        <text>{{ orderStatusValue }}</text>
      </view>
    </view>

    <!-- <view class="goodsList">
      <view class="title">普通商品</view>
      <view class="goods">
        <view v-for="(i,ins) in temporary_list" :key="ins" class="recommend_item">
          <image class="original" :src="i.image?i.image:staticUrl()+'/home/defaultImg.png'">
          </image>
          <view style="width:54%">
            <view class="goodsName ">
              <text class="singleRowEllipsis">{{i.goodsName}}</text>
              <text class="num">x{{i.num}}</text>
            </view>
            <view class="simpleSpecs singleRowEllipsis">规格：{{i.simpleSpecs}}</view>
            <view class="expirationDate">
              <img :src="staticUrl() + '/home/expirationDate.png'" alt="" class="_icon">
              <text>{{i.expirationDate}}</text>
            </view>
            <view class="manufacturer singleRowEllipsis">
              <img :src="staticUrl() + '/home/manufacturer.png'" alt="" class="_icon">
              <text>{{i.manufacturer}}</text>
            </view>
            <view class="activityType" v-if="i.promotion">
              {{i.promotion.promotionName}}
            </view>
            <view class="prices">
              <view> ￥{{i.goodsPrice}} </view>
              <text class="num" v-if="i.outboundNum">出库:{{i.outboundNum}}</text>
            </view>
          </view>
        </view>
        <view class="more" @click="more" v-if="orderItems.length > 2">
          <text>{{openArrowText}}</text>
          <image :src="staticUrl() + openArrow" mode="aspectFit"></image>
        </view>
      </view>
    </view> -->
    <view v-if="orderItems.length">
      <Order :temporary_list="temporary_list" :orderItems="orderItems"> </Order>
    </view>

    <!--  -->
    <view class="afterSalesType">
      <text class="type">选择售后类型</text>
      <view class="refund" @click="refund">
        <image :src="staticUrl() + '/setting/refund.png'" mode="aspectFit" class="icon"></image>
        <text> 仅退款 </text>
        <image :src="staticUrl() + '/setting/right.png'" mode="aspectFit" class="right"></image>
      </view>
      <view class="returnGoods" @click="returnGoods">
        <image :src="staticUrl() + '/setting/returnGoods.png'" mode="aspectFit" class="icon">
        </image>
        <text> 退货退款 </text>
        <image :src="staticUrl() + '/setting/right.png'" mode="aspectFit" class="right"></image>
      </view>
    </view>
  </view>
</template>

<script>
import { orderDetails } from '@/api/order/index.js'
import Order from '@/components/order/index.vue'

export default {
  components: { Order },
  data () {
    return {
      sn: '',
      orderStatusValue: '',
      orderItems: [],
      temporary_list: [],
      openArrowText: '全部打开',
      openArrow: '/carts/moreRule.png'
    }
  },
  onLoad (e) {
    this.sn = e.sn
    this.getList()
  },
  methods: {
    getList () {
      orderDetails(this.sn, { unfolded: false }).then(res => {
        if (res.code === 200) {
          this.orderStatusValue = res.data.orderStatusValue
          this.orderItems = res.data.orderItems
          this.temporary_list = res.data.orderItems.slice(0, 2)
        }
      })
    },
    refund () {
      uni.navigateTo({ url: '/subpackage/order/refund?sn=' + this.sn })
    },
    returnGoods () {
      uni.navigateTo({ url: '/subpackage/order/returnGoods?sn=' + this.sn })
    },
    // 查看更多
    more () {
      if (this.openArrowText === '收起') {
        this.openArrowText = '全部打开'
        this.openArrow = '/carts/moreRule.png'
        this.temporary = this.orderItems.slice(0, 2)
      } else {
        this.openArrowText = '收起'
        this.openArrow = '/carts/putAway.png'
        this.temporary = this.orderItems
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.applyAfterSales_container {
  width: 100%;
  min-height: 100vh;
  background: #f9f9f9;
  padding-top: 25rpx;

  .orderStatus {
    background: #fff;
    border-radius: 11rpx;
    margin: 0 25rpx;
    margin-bottom: 25rpx;
    padding: 45.83rpx 20.14rpx;

    view {
      font-size: 28rpx;
      color: #585858;

      text {
        margin-right: 22.22rpx;
      }
    }

    view:nth-child(2) {
      margin-top: 31.25rpx;
    }
  }

  .goodsList {
    background: #fff;
    margin: 0 25rpx;
    border-radius: 11rpx;

    .title {
      font-size: 29rpx;
      font-weight: bold;
      padding: 38.19rpx 0 20.14rpx 22.22rpx;
      border-bottom: 1px solid #f5f5f5;
    }

    .goods {
      .recommend_item {
        display: flex;
        border-bottom: 1px solid #f5f5f5;

        .num {
          color: #8d8d8d;
          float: right;
          font-size: 25rpx;
        }

        .original {
          width: 194rpx;
          height: 194rpx;
          background: #ffffff;
          padding: 34.72rpx 21rpx;
          margin: 44.44rpx 59.03rpx 58.33rpx 37.5rpx;
          box-sizing: border-box;
        }

        .goodsName {
          font-size: 29rpx;
          margin-top: 38.19rpx;
          margin-bottom: 19.44rpx;
          display: flex;
          justify-content: space-between;

          text:nth-child(1) {
            width: 80%;
          }
        }

        .simpleSpecs {
          font-size: 21rpx;
          margin-bottom: 14.58rpx;
          color: #8d8d8d;
        }

        .expirationDate {
          font-size: 21rpx;
          margin-bottom: 14.58rpx;
          color: #8d8d8d;
        }

        ._icon {
          width: 20rpx;
          height: 20rpx;
          vertical-align: middle;
          margin-right: 7.64rpx;
        }

        .manufacturer {
          font-size: 20rpx;
          margin-bottom: 14.58rpx;
          color: #8d8d8d;
        }

        .activityType {
          display: inline-block;
          font-size: 19rpx;
          color: #ef231b;
          border: 1px solid #ef231b;
          padding: 0 8.6rpx;
          border-radius: 4rpx;
          margin-top: 13.89rpx;
        }

        .prices {
          display: flex;
          justify-content: space-between;
          align-items: flex-end;
          margin-top: 25rpx;

          view {
            color: #ec1818;
            font-weight: bold;
            font-size: 30rpx;

            text {
              font-size: 25rpx;
              font-weight: normal;
              color: #8d8d8d;
              margin-left: 6.94rpx;
            }
          }
        }
      }

      .more {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 27.38rpx 0;

        text {
          font-size: 29rpx;
          font-weight: bold;
        }

        image {
          max-width: 16.67rpx;
          height: 11.11rpx;
          margin-left: 12.5rpx;
        }
      }
    }
  }

  .afterSalesType {
    height: 376rpx;
    background: #ffffff;
    border-radius: 11rpx;
    margin: 25rpx;
    font-size: 33rpx;
    font-weight: bold;
    padding-left: 22.22rpx;
    padding-top: 58.33rpx;

    .refund,
    .returnGoods {
      height: 100rpx;
      line-height: 140rpx;

      .icon {
        width: 29.17rpx;
        height: 29.17rpx;
      }

      text {
        margin-left: 13.89rpx;
      }

      .right {
        width: 9.72rpx;
        height: 15.28rpx;
        float: right;
        padding-top: 64rpx;
        padding-right: 60rpx;
      }
    }

    .refund {
      margin-top: 29.17rpx;
    }

    .returnGoods {
      margin-top: 6.81rpx;
    }
  }
}
</style>
